import * as requestService from './request';

function filterResult(result) {
  if (result.success) {
    return result.data;
  }
  return [];
}

export function getTopics(zoneId, menuKey = 'all', submenuKey = '') {
  return requestService.post('/topics', { zoneId, menuKey, submenuKey }).then(filterResult);
}

export function getTopicById(id) {
  return requestService.post(`/topic/${id}/data`).then(filterResult);
}
